package com.hgg.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import com.hgg.utils.WebJsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.hgg.service.TProductService;
import com.hgg.utils.JsonUtils;

@Controller
public class TProductController {
	@Autowired
	private TProductService tProductService;
	private static int cartId=1;
	

	@Scheduled(cron= "*/20 * * * * ?")
	public void insertBatch() throws Exception {
		//FileInputStream inputStream = new FileInputStream(new File("F://NB//json.json"));
		if(cartId<=16) {
			WebJsonUtil.setURLMap("9k9", cartId);
			cartId++;
		}else if(cartId<=32){
			WebJsonUtil.setURLMap("20k", cartId-16);
			cartId++;
		}else {
			cartId=1;
              throw new Exception();
		}
		List<Map<String, Object>> list = WebJsonUtil.getListMap();

		int i = tProductService.insertBatch(list);
		System.out.println(i);



	}
	

}
